﻿//#include "../3rdparty/pugixml/pugixml.hpp"
#include "zyForm.h"

BlackMoonUI::zyForm::zyForm() : zyWindow()
{
	SetMember(L"this", (LONG_PTR)this);
	m_obj->setWndProc(zyForm_WndProc);
	m_obj->setDestroy(zyForm_Destroy);
	SetMember(L"scrollx_delta", 5);
	SetMember(L"scrolly_delta", 20);
}
BlackMoonUI::zyForm::~zyForm()
{

}
void WINAPI BlackMoonUI::zyForm::zyForm_Destroy(zyObject* obj)
{
	zyForm* zyf = (zyForm*)obj->getPtrData(L"this");
	zyf->OnNCDestroy();
	zyWindow::zyWindow_Destroy(obj);
}
LRESULT  WINAPI BlackMoonUI::zyForm::zyForm_WndProc(zyObject* obj, HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL* bHandled)
{
	//std::wcout << "WM_VSCROLL" << (uMsg == WM_VSCROLL) << std::endl;
	switch (uMsg) {
	case WM_NCDESTROY:
	{
		zyForm* zyf = static_cast<zyForm*>(obj->getPtrData(L"this"));
		if (zyf) zyf->OnNCDestroy();
	}
	break;
	case WM_ERASEBKGND:
	{
		if (OnDrawBack(hWnd, (HDC)wParam)) {
			*bHandled = true;
			return 1;
		}
	}
	break;
	case WM_CREATE: case WM_INITDIALOG:
	{
		zyForm* zyf = static_cast<zyForm*>(obj->getPtrData(L"this"));
		TRegEvent* evtPtr = obj->getRegEvent(L"XmlresOnCreate");//从资源创建触发的事件
		if (evtPtr != nullptr) {
			evtPtr->handler<LRESULT>(zyf, obj->getPtrData(L"XmlNode"));
		}
		//if (zyf && zyf->被创建(zyf)){//虚函数方式回调
		//	return 0;
		//}
		evtPtr = obj->getRegEvent(L"OnCreate");
		if (evtPtr != nullptr) {
			zyForm* zyf = static_cast<zyForm*>(obj->getPtrData(L"this"));
			evtPtr->handler<LRESULT>(zyf);
		}
		RECT rc;
		GetClientRect(hWnd, &rc);
		SendMessage(hWnd, WM_SIZE, 0, MAKELPARAM(rc.right - rc.left, rc.bottom - rc.top));
	}
	break;
	case WM_CLOSE:
	{
		TRegEvent* evtPtr = obj->getRegEvent(L"OnClose");
		if (evtPtr != nullptr) {
			LRESULT ret = evtPtr->handler<LRESULT>(hWnd);
			if (ret != 0) {
				*bHandled = true;
				return 1;
			}
		}
		zyForm* zyf = static_cast<zyForm*>(obj->getPtrData(L"this"));
		zyf->zyForm_OnClose(hWnd);
	}
	break;
	case WM_DESTROY:
	{
		//事件_将被销毁
		TRegEvent* evtPtr = obj->getRegEvent(L"OnDestory");
		if (evtPtr != nullptr) {
			evtPtr->handler<LRESULT>(hWnd);
			*bHandled = TRUE;
			return(0);
		}
	}
	break;
	case WM_MOVE:
	{
		TRegEvent* evtPtr = obj->getRegEvent(L"OnMove");
		if (evtPtr != nullptr) {
			evtPtr->handler<LRESULT>(hWnd, LOWORD(lParam), HIWORD(lParam));
		}
	}
	break;
	case WM_SIZE:
	{
		zyForm* zyf = static_cast<zyForm*>(obj->getPtrData(L"this"));
		zyf->zyForm_OnSize(hWnd, LOWORD(lParam), HIWORD(lParam));
		TRegEvent* evtPtr = obj->getRegEvent(L"OnSize");
		if (evtPtr != nullptr) {
			evtPtr->handler<LRESULT>(hWnd, LOWORD(lParam), HIWORD(lParam));
		}
	}
	break;
	case WM_ACTIVATE:
	{
		int ret = LOWORD(wParam);
		if (ret != 0) {
			TRegEvent* evtPtr = obj->getRegEvent(L"OnActivate");
			if (evtPtr != nullptr) {
				evtPtr->handler<LRESULT>(hWnd);
			}
		}
		else {
			TRegEvent* evtPtr = obj->getRegEvent(L"OnUnActivate");
			if (evtPtr != nullptr) {
				evtPtr->handler<LRESULT>(hWnd);
			}
		}
	}
	break;
	case WM_SHOWWINDOW:
	{
		if (wParam != 0) {
			TRegEvent* evtPtr = obj->getRegEvent(L"OnShow");
			if (evtPtr != nullptr) {
				evtPtr->handler<LRESULT>(hWnd);
			}
		}
		else {
			TRegEvent* evtPtr = obj->getRegEvent(L"OnHide");
			if (evtPtr != nullptr) {
				evtPtr->handler<LRESULT>(hWnd);
			}
		}
	}
	break;
	case WM_COMMAND:
	{
		int id = LOWORD(wParam);
		int ret = HIWORD(wParam);
		if (lParam == 0 && (ret == 0 || ret == 1)) {
			zyForm* zyf = static_cast<zyForm*>(obj->getPtrData(L"this"));
			if (zyf && ret == 0 && zyf->zyForm_DefaulCommand(id)) {
				*bHandled = true;
				return 1;
			}
			TRegEvent* evtPtr = obj->getRegEvent(L"OnMenuItemClick");
			if (evtPtr != nullptr) {
				evtPtr->handler<LRESULT>(zyf, id);
			}
		}
	}
	break;
	case 12313://托盘消息
	{
		TRegEvent* evtPtr = obj->getRegEvent(L"OnNotifIcon");
		if (evtPtr != nullptr) {
			switch ((int)lParam)
			{
			case WM_LBUTTONDOWN:
				SetCapture(hWnd);
				break;
			case WM_RBUTTONDOWN:
				SetCapture(hWnd);
				break;
			case WM_LBUTTONDBLCLK:
				evtPtr->handler<LRESULT>(hWnd, 3);//#托盘_左键双击
				break;
			case WM_RBUTTONDBLCLK:
				evtPtr->handler<LRESULT>(hWnd, 4);//#托盘_右键双击
				break;
			case WM_MOUSEMOVE:
				evtPtr->handler<LRESULT>(hWnd, 5);//#托盘_鼠标移动
				break;
			case 1026:
				evtPtr->handler<LRESULT>(hWnd, 6);//#托盘_显示气泡
				break;
			case 1028:
				evtPtr->handler<LRESULT>(hWnd, 7);//#托盘_气泡消失
				break;
			case 1029:
				evtPtr->handler<LRESULT>(hWnd, 8);//#托盘_单击气泡
				break;
			case WM_LBUTTONUP:
				evtPtr->handler<LRESULT>(hWnd, 1);//#托盘_左键单击
				ReleaseCapture();
				break;
			case WM_RBUTTONUP:
				evtPtr->handler<LRESULT>(hWnd, 2);//#托盘_右键单击
				ReleaseCapture();
				break;
			}
		}
	}
	break;
	case WM_NCACTIVATE:
	{
		if (wParam == 0 && obj->getPtrData(L"NCEverActive") != 0) {
			*bHandled = TRUE;
			return 1;
		}
	}
	break;
	case WM_LBUTTONDOWN:
	{
		if (obj->getPtrData(L"FreeMove") != 0) {
			SendMessage(hWnd, WM_SYSCOMMAND, SC_MOVE | HTCAPTION, 0);
		}
	}
	break;
	case WM_GETMINMAXINFO:
	{
		zyForm* zyf = static_cast<zyForm*>(obj->getPtrData(L"this"));
		int ret = zyf->zyForm_OnGetMinMaxInfo(hWnd, reinterpret_cast<MINMAXINFO*>(lParam), bHandled);
		if (ret != 0) {
			*bHandled = TRUE;
			return ret;
		}
	}
	break;
	case WM_INITMENUPOPUP:
	{
		TRegEvent* evtPtr = obj->getRegEvent(L"OnInitMenuPopup");
		if (evtPtr != nullptr) {
			evtPtr->handler<LRESULT>(hWnd, wParam, LOWORD(lParam), HIWORD(lParam));
			*bHandled = TRUE;
			return 0;
		}
	}
	break;
	case WM_MENUSELECT:
	{
		TRegEvent* evtPtr = obj->getRegEvent(L"OnMenuSelect");
		if (evtPtr != nullptr) {
			evtPtr->handler<LRESULT>(hWnd, lParam, LOWORD(wParam), (wParam >> 16));
			*bHandled = TRUE;
			return 0;
		}
	}
	break;
	case WM_SYSCOMMAND:
	{
		if (wParam == SC_CLOSE) {
			TRegEvent* evtPtr = obj->getRegEvent(L"OnUserClose");
			if (evtPtr != nullptr) {
				LRESULT ret = evtPtr->handler<LRESULT>(hWnd);
				if (ret != 0) {
					*bHandled = TRUE;
					return 0;
				}
			}
		}
		TRegEvent* evtPtr = obj->getRegEvent(L"OnSysCommand");
		if (evtPtr != nullptr) {
			evtPtr->handler<LRESULT>(hWnd, wParam, LOWORD(lParam), (lParam >> 16));
			return 0;
		}
	}
	break;
	case WM_ACTIVATEAPP:
	{
		if (obj->getPtrData(L"FirstActivte") == 0 && wParam != 0) {
			obj->setPtrData(L"FirstActivte", (void*)1);
			TRegEvent* evtPtr = obj->getRegEvent(L"OnFirstActivate");
			if (evtPtr != nullptr) {
				SendMessage(hWnd, WM_NCACTIVATE, 1, 0);
				evtPtr->handler<LRESULT>(hWnd);
			}
		}
	}
	break;
	case WM_SETCURSOR:
	{
		void* evtPtr = obj->getPtrData(L"WaitCursor");
		if (evtPtr != nullptr) {
			*bHandled = TRUE;
			SetCursor(LoadCursor(NULL, IDC_WAIT));
			return 1;
		}
	}
	break;
	case WM_HSCROLL: {
		INT ScrollMode = (INT)(INT_PTR)obj->getPtrData(L"ScrollMode");
		if ((ScrollMode & 内置滚动条_水平) != 0 || (ScrollMode & 内置滚动条_垂直始终显示) != 0) {
			*bHandled = TRUE;
			zyForm* zyf = static_cast<zyForm*>(obj->getPtrData(L"this"));
			return zyf->zyForm_OnHScroll(hWnd, ScrollMode, LOWORD(wParam), HIWORD(wParam));
		}
	}
	break;
	case WM_VSCROLL: {
		INT ScrollMode = (INT)(INT_PTR)obj->getPtrData(L"ScrollMode");
		if ((ScrollMode & 内置滚动条_垂直) != 0 || (ScrollMode & 内置滚动条_垂直始终显示) != 0) {
			*bHandled = TRUE;
			zyForm* zyf = static_cast<zyForm*>(obj->getPtrData(L"this"));
			return zyf->zyForm_OnVScroll(hWnd, ScrollMode, LOWORD(wParam), HIWORD(wParam));
		}
	}
	break;
	case WM_MOUSEWHEEL: {
		INT ScrollMode = (INT)(INT_PTR)obj->getPtrData(L"ScrollMode");
		if ((ScrollMode & 内置滚动条_垂直) != 0 || (ScrollMode & 内置滚动条_垂直始终显示) != 0) {
			*bHandled = TRUE;
			zyForm* zyf = static_cast<zyForm*>(obj->getPtrData(L"this"));
			return zyf->zyForm_OnMouseWhell(hWnd, HIWORD(wParam), LOWORD(lParam), HIWORD(lParam));
		}
	}
	break;
	case SPL_ONSCROLL: {
		int oldPos = HIWORD(lParam);
		int newPos = LOWORD(lParam);
		if (wParam == SB_HORZ)
			ScrollWindow(hWnd, oldPos - newPos, 0, 0, 0);
		else
			ScrollWindow(hWnd, 0, oldPos - newPos, 0, 0);
		TRegEvent* evtPtr = obj->getRegEvent(L"OnScroll");
		if (evtPtr != nullptr) {
			evtPtr->handler<LRESULT>(hWnd, wParam, oldPos, newPos);
		}
	}
	break;
	default:
		if (uMsg == (UINT)(UINT_PTR)obj->getPtrData(L"TaskbarCreatedMsg")) {//任务栏被重建
			void* evtPtr = obj->getPtrData(L"NotifyiconData");
			if (evtPtr != 0) {
				NOTIFYICONDATA* e = reinterpret_cast<NOTIFYICONDATA*>(evtPtr);
				Shell_NotifyIcon(NIM_DELETE, e);
				//e.cbSize = sizeof(NOTIFYICONDATA);
				//e.hWnd = hwnd;
				//e.uID = IDI_ICON1;
				e->uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
				//e.uCallbackMessage = WM_IAWENTRAY;
				//e.hIcon = LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_ICON1));
				//strcpy_s(e.szTip, 20, "我太难了！"); //添加的托盘提示符字符串，鼠标放在托盘处会显示提示文字

				Shell_NotifyIcon(NIM_ADD, e);
			}
		}
	}
	return zyWindow::zyWindow_WndProc(obj, hWnd, uMsg, wParam, lParam, bHandled);
}
int BlackMoonUI::zyForm::zyForm_OnHScroll(HWND hWnd, int mode, int nSBCode, int nPos) {
	SCROLLINFO si = {0};
	si.cbSize = sizeof(SCROLLINFO);
	si.fMask = SIF_POS | SIF_PAGE | SIF_RANGE | SIF_TRACKPOS;
	GetScrollInfo(hWnd, SB_HORZ, &si);
	int delta = (INT)(INT_PTR)GetMember(L"scrollx_delta");
	int nPrevPos = si.nPos;
	if(nSBCode == SB_LEFT)
		si.nPos = si.nMin;
	else if (nSBCode == SB_RIGHT)
		si.nPos = si.nMax;
	else if (nSBCode == SB_LINELEFT)
		si.nPos = si.nPos - delta;
	else if (nSBCode == SB_LINERIGHT)
		si.nPos = si.nPos + delta;
	else if (nSBCode == SB_PAGELEFT)
		si.nPos = si.nPos - si.nPage;
	else if (nSBCode == SB_PAGERIGHT)
		si.nPos = si.nPos + si.nPage;
	else if (nSBCode == SB_THUMBTRACK)
		si.nPos = si.nTrackPos;

	if (si.nPos < si.nMin)
		si.nPos = si.nMin;
	else if(si.nPos > (int)(si.nMax - si.nPage))
		si.nPos = si.nMax - si.nPage;

	si.fMask = SIF_POS;
	if ((mode & 内置滚动条_水平始终显示) != 0){
		si.fMask = si.fMask | SIF_DISABLENOSCROLL;
	}
	SetScrollInfo(hWnd, SB_HORZ, &si, true);
	if (si.nPos != nPrevPos) {
		SendMessage(hWnd, SPL_ONSCROLL, SB_HORZ, MAKEWPARAM(si.nPos, nPrevPos));
	}
	return 0;
}
int BlackMoonUI::zyForm::zyForm_OnVScroll(HWND hWnd, int mode, int nSBCode, int nPos) {
	SCROLLINFO si = {0};
	si.cbSize = sizeof(SCROLLINFO);
	si.fMask = SIF_POS | SIF_PAGE | SIF_RANGE | SIF_TRACKPOS;
	GetScrollInfo(hWnd, SB_VERT, &si);
	int delta = (int)GetMember(L"scrolly_delta");
	int nPrevPos = si.nPos;
	if(nSBCode == SB_TOP)
		si.nPos = si.nMin;
	else if(nSBCode == SB_BOTTOM)
		si.nPos = si.nMax;
	else if (nSBCode == SB_LINEUP)
		si.nPos = si.nPos - delta;
	else if (nSBCode == SB_LINEDOWN)
		si.nPos = si.nPos + delta;
	else if (nSBCode == SB_PAGEUP)
		si.nPos = si.nPos - si.nPage;
	else if (nSBCode == SB_PAGEDOWN)
		si.nPos = si.nPos + si.nPage;
	else if (nSBCode == SB_THUMBTRACK)
		si.nPos = si.nTrackPos;

	if (si.nPos < si.nMin)
		si.nPos = si.nMin;
	else if (si.nPos > (int)(si.nMax - si.nPage))
		si.nPos = si.nMax - si.nPage;

	si.fMask = SIF_POS;
	if ((mode & 内置滚动条_垂直始终显示) != 0){
		si.fMask = si.fMask | SIF_DISABLENOSCROLL;
	}
	SetScrollInfo(hWnd, SB_VERT, &si, true);
	if (si.nPos != nPrevPos) {
		SendMessage(hWnd, SPL_ONSCROLL, SB_VERT, MAKEWPARAM(si.nPos, nPrevPos));
	}
	return 0;
}
int BlackMoonUI::zyForm::zyForm_OnMouseWhell(HWND hWnd, int delta, int x, int y) {
	SCROLLINFO si = {0};
	int scrollLines = 0;
	si.fMask = SIF_ALL;
	GetScrollInfo(hWnd, SB_VERT, &si);
	int oldPos = si.nPos;
	SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &scrollLines, 0);
	scrollLines = scrollLines > 0 ? scrollLines : 1;
	int vDelta = (int)GetMember(L"scrolly_delta");
	vDelta = delta / 120 * scrollLines * vDelta;
	int newPos = si.nPos - vDelta;
	newPos = max(si.nMin, min(newPos, int(si.nMax - si.nPage + 1)));
	if (newPos != si.nPos) {
		SetScrollPos(hWnd, SB_VERT, newPos, 1);
		SendMessage(hWnd, SPL_ONSCROLL, SB_VERT, MAKEWPARAM(newPos, oldPos));
	}
	return 0;
}
void BlackMoonUI::zyForm::zyForm_OnSize(HWND hWnd, int cx, int cy) {
	int newXPos=0;
	int newYPos=0;
	SCROLLINFO si = {0};
	int ScrollMode = (int)GetMember(L"ScrollMode");
	int contentWidth = (int)GetMember(L"contentWidth");
	si.cbSize = sizeof(SCROLLINFO);
	si.fMask = SIF_ALL;
	GetScrollInfo(hWnd, SB_HORZ, &si);
	int oldXPos = si.nPos;
	int oldXPage = si.nPage;
	int scrollRangX = contentWidth + GetSystemMetrics(SM_CXVSCROLL);
	si.fMask = SIF_PAGE | SIF_RANGE | SIF_POS;
	if (scrollRangX <= cx) 
		newXPos = 0;
	else 
		newXPos = min(scrollRangX - cx, oldXPos);
	si.nMin = 0;
	if ((ScrollMode & 内置滚动条_水平) != 0 || (ScrollMode, 内置滚动条_水平始终显示) != 0)
		si.nMax = scrollRangX;
	else 
		si.nMax = 0;
	si.nPage = cx;
	si.nPos = newXPos;
	if ((ScrollMode & 内置滚动条_水平始终显示) != 0)
		si.fMask = si.fMask | SIF_DISABLENOSCROLL;
	SetScrollInfo(hWnd, SB_HORZ, &si, true);


	int contentHeight = (int)GetMember(L"contentHeight");
	SCROLLINFO si1 = { 0 };
	si1.cbSize = sizeof(SCROLLINFO);
	si1.fMask = SIF_ALL;
	GetScrollInfo(hWnd, SB_VERT, &si1);
	int oldYPos = si1.nPos;
	int oldYPage = si1.nPage;
	int scrollRangY = contentHeight + GetSystemMetrics(SM_CXHSCROLL);
	si1.fMask = SIF_PAGE | SIF_RANGE | SIF_POS;
	if (scrollRangY <= cy) 
		newYPos = 0;
	else 
		newYPos = min(scrollRangY - cy, oldYPos);
	si1.nMin = 0;
	if ((ScrollMode & 内置滚动条_垂直) != 0 || (ScrollMode, 内置滚动条_垂直始终显示) != 0)
		si1.nMax = scrollRangY;
	else 
		si1.nMax = 0;
	si1.nPos = newYPos;
	si1.nPage = cy;
	if ((ScrollMode & 内置滚动条_垂直始终显示) != 0)
		si1.fMask = si1.fMask | SIF_DISABLENOSCROLL;
	SetScrollInfo(hWnd, SB_VERT, &si1, true);

	if (oldXPos != newXPos) 
		SendMessage(hWnd, SPL_ONSCROLL, SB_HORZ, MAKEWPARAM(newXPos, oldXPos));
	if (oldYPos != newYPos) 
		SendMessage(hWnd, SPL_ONSCROLL, SB_VERT, MAKEWPARAM(newYPos, oldYPos));

}
void BlackMoonUI::zyForm::OnNCDestroy() {
	LONG_PTR NotifyIcon = 0;
	LONG_PTR pBackImage = GetMember(L"pBackImage");
	if (pBackImage != 0) {
		//IUnknown_Release(pBackImage)
		//GPImage* Image = (GPImage*)pBackImage;
		//Image->Destory();
		SetMember(L"pBackImage", 0);
	}

	LONG_PTR NotifyiconData = GetMember(L"NotifyiconData");
	if (NotifyiconData != 0) {
		NotifyIcon = GetMember(L"NotifyIcon");
		if (NotifyIcon != 0) {
			DestroyIcon((HICON)NotifyIcon);
			SetMember(L"NotifyIcon", 0);
		}
		Shell_NotifyIcon(NIM_DELETE, (PNOTIFYICONDATAW)NotifyiconData);
		free((void*)NotifyiconData);
		SetMember(L"NotifyiconData", 0);
	}

	LONG_PTR hAccelTable = GetMember(L"hAccelTable");
	if (hAccelTable != 0) {
		DestroyAcceleratorTable((HACCEL)hAccelTable);
		SetMember(L"hAccelTable", 0);
	}

	LONG_PTR pLinks = GetMember(L"ATLWindows");
	if (pLinks != 0) {
		//LinkList_Destroy((HIMAGELIST)pLinks);
		SetMember(L"ATLWindows", 0);
	}

	LONG_PTR DefaultButton = GetMember(L"DefaultButton");
	if (DefaultButton != 0) {
		//IUnknown_Release(DefaultButton)
		SetMember(L"DefaultButton", 0);
	}

	LONG_PTR hIcon = GetMember(L"BigIcon");
	if (hIcon != 0) {
		DestroyIcon((HICON)hIcon);
		SetMember(L"BigIcon", 0);
	}
	hIcon = GetMember(L"SmallIcon");
	if (hIcon != 0) {
		DestroyIcon((HICON)hIcon);
		SetMember(L"SmallIcon", 0);
	}

	SetMember(L"FirstActivte", 0);

	
}
BOOL BlackMoonUI::zyForm::zyForm_DefaulCommand(int id) {
	LONG_PTR Button = 0;
	HWND hWnd = 0;
	if (id == IDOK) {//对话框返回值_确认
		Button = GetMember(L"DefaultButton");
		if (Button != 0) {
			zyBase* ht = (zyBase*)Button;
			hWnd = (HWND)ht->GetMember(L"hWnd");
			SendMessage(hWnd, BM_CLICK, 0, 0);
		}
		return(true);
	}
	if (id == IDCANCEL) {//对话框返回值_取消
		Button = GetMember(L"CancelButton");
		if (Button != 0) {
			zyBase* ht = (zyBase*)Button;
			hWnd = (HWND)ht->GetMember(L"hWnd");
			SendMessage(hWnd, BM_CLICK, 0, 0);
		}
		LONG_PTR EscClose = GetMember(L"EscClose");
		if (EscClose != 0) {
			hWnd = (HWND)GetMember(L"hWnd");
			SendMessage(hWnd, WM_CLOSE, 0, 0);
		}
		return(true);
	}
	return(false);
}
void BlackMoonUI::zyForm::zyForm_OnClose(HWND hWnd)
{
	HWND hWndParent = (HWND)GetWindowLongPtr(hWnd, GWLP_HWNDPARENT);
	if (IsWindow(hWndParent) && IsWindowVisible(hWndParent) && !IsWindowEnabled(hWndParent)) {
		EnableWindow(hWndParent, TRUE);
		SetWindowPos(hWndParent, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
	}
}
int BlackMoonUI::zyForm::zyForm_OnGetMinMaxInfo(HWND hWnd, MINMAXINFO *pInfo, BOOL* bHandled)
{
	zyObject* pLayout = (zyObject*)GetMember(L"zyLayout");
	if (pLayout != 0){	
		LRESULT minSize = pLayout->callWndProc(hWnd,zyLYM_GETMINSIZE, 0, 0, bHandled);
		RECT rc, rcClient;
		GetWindowRect(hWnd, &rc);
		GetClientRect(hWnd, &rcClient);
		int ncWidth = rc.right - rc.left -(rcClient.right - rcClient.left);
		int ncHeight = rc.bottom - rc.top -(rcClient.bottom - rcClient.top);
		pInfo->ptMinTrackSize.x = LOWORD(minSize) + ncWidth;
		pInfo->ptMinTrackSize.y = HIWORD(minSize) + ncHeight;
		return 1;
	}
	return 0;
}
int BlackMoonUI::zyForm::边框(int Border) {
	int nBorder = getBorder();
	if (Border != -1) {
		setBorder(Border);
		if (是否已创建()) {
			HWND hWnd = getHwnd();
			DWORD style = (DWORD)GetWindowLongPtr(hWnd, GWL_STYLE);
			DWORD exStyle = (DWORD)GetWindowLongPtr(hWnd, GWL_EXSTYLE);
			_SetWindowBorder(Border, style, exStyle);
			SetWindowLongPtr(hWnd, GWL_STYLE, style);
			SetWindowLongPtr(hWnd, GWL_EXSTYLE, exStyle);
			SetWindowPos(hWnd, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED);
		}
	}
	return nBorder;
}

BOOL BlackMoonUI::zyForm::托盘气泡提示(const std::wstring& 参数_气泡内容, const std::wstring& 参数_气泡标题, int 参数_气泡图标, int 参数_气泡显示时间) {
	NOTIFYICONDATA* NotifyiconData = (NOTIFYICONDATA*)GetMember(L"NotifyiconData");
	if (NotifyiconData == nullptr)
		return (FALSE);
	int 局部_气泡图标 = 0;
	if (参数_气泡图标 == 0)
		局部_气泡图标 = 1;
	else
		局部_气泡图标 = 参数_气泡图标;
	int 局部_气泡显示时间 = 0;
	if (参数_气泡显示时间 == 0)
		局部_气泡显示时间 = 10000;
	else
		局部_气泡显示时间 = 参数_气泡显示时间;
	NotifyiconData->uFlags = NIF_TIP | NIF_ICON | NIF_MESSAGE | NIF_INFO | NIF_STATE;
	//_tcscpy(NotifyiconData->szInfo, 参数_气泡内容);
	wcscpy_s(NotifyiconData->szInfo, 参数_气泡内容.size(), 参数_气泡内容.c_str());
	NotifyiconData->uTimeout = 局部_气泡显示时间;
	//_tcscpy(NotifyiconData->szInfoTitle, 参数_气泡标题);
	wcscpy_s(NotifyiconData->szInfo, 参数_气泡标题.size(), 参数_气泡标题.c_str());
	NotifyiconData->dwInfoFlags = 局部_气泡图标;
	return Shell_NotifyIcon(NIM_MODIFY, NotifyiconData) != 0;
}
BOOL BlackMoonUI::zyForm::托盘修改图标(zyIcon& 参数_图标) {
	NOTIFYICONDATA* NotifyiconData = (NOTIFYICONDATA*)GetMember(L"NotifyiconData");
	if (NotifyiconData == nullptr)
		return (false);
	HICON NotifyIcon = (HICON)GetMember(L"NotifyIcon");
	if (NotifyIcon != 0)
		DestroyIcon(NotifyIcon);
	NotifyIcon = CopyIcon((HICON)参数_图标.getIcon());
	SetMember(L"NotifyIcon", (LONG_PTR)NotifyIcon);
	NotifyiconData->uFlags = NIF_TIP | NIF_ICON | NIF_MESSAGE;
	NotifyiconData->hIcon = NotifyIcon;
	return Shell_NotifyIcon(NIM_MODIFY, NotifyiconData) != 0;
}
BOOL BlackMoonUI::zyForm::托盘修改提示文本(const std::wstring& 参数_提示文本) {
	NOTIFYICONDATA* NotifyiconData = (NOTIFYICONDATA*)GetMember(L"NotifyiconData");
	if (NotifyiconData == nullptr)
		return false;
	NotifyiconData->uFlags = NIF_TIP | NIF_ICON | NIF_MESSAGE;//图标样式
	//_tcscpy(NotifyiconData->szTip, 参数_提示文本);//当鼠标移动到图标的时候显示
	wcscpy_s(NotifyiconData->szInfo, 参数_提示文本.size(), 参数_提示文本.c_str());
	return Shell_NotifyIcon(NIM_MODIFY, NotifyiconData) != 0;
}
BOOL BlackMoonUI::zyForm::置托盘图标(zyIcon& 参数_图标, const std::wstring& 参数_提示文本) {
	if (参数_图标.getIcon() == 0)
		return (托盘删除图标());
	LONG_PTR TaskbarCreatedMsg = GetMember(L"TaskbarCreatedMsg");
	if (TaskbarCreatedMsg == 0) {
		TaskbarCreatedMsg = RegisterWindowMessage(L"TaskbarCreated");
		SetMember(L"TaskbarCreatedMsg", (LONG_PTR)TaskbarCreatedMsg);
	}
	NOTIFYICONDATA* NotifyiconData = (NOTIFYICONDATA*)GetMember(L"NotifyiconData");
	if (NotifyiconData != nullptr)
		delete NotifyiconData;
	NotifyiconData = new NOTIFYICONDATA;
	SetMember(L"NotifyiconData", (LONG_PTR)NotifyiconData);

	HICON NotifyIcon = (HICON)GetMember(L"NotifyIcon");
	if (NotifyIcon != 0)
		DestroyIcon(NotifyIcon);
	NotifyIcon = CopyIcon((HICON)参数_图标.getIcon());
	SetMember(L"NotifyIcon", (LONG_PTR)NotifyIcon);

	NotifyiconData->hIcon = NotifyIcon;
	NotifyiconData->cbSize = sizeof(NOTIFYICONDATA);
	NotifyiconData->hWnd = 取窗口句柄();
	NotifyiconData->uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
	NotifyiconData->uCallbackMessage = 12313;
	//_tcscpy(NotifyiconData->szTip, 参数_提示文本);//当鼠标移动到图标的时候显示
	wcscpy_s(NotifyiconData->szInfo, 参数_提示文本.size(), 参数_提示文本.c_str());
	return Shell_NotifyIcon(NIM_ADD, NotifyiconData) != 0;
}
BOOL BlackMoonUI::zyForm::置外形圆角(int 参数_圆角角度) {
	RECT rect = { 0 };
	GetWindowRect(取窗口句柄(), &rect);
	HRGN hRgn = CreateRoundRectRgn(0, 0, rect.right - rect.left, rect.bottom - rect.top, 参数_圆角角度, 参数_圆角角度);
	int ret = SetWindowRgn(取窗口句柄(), hRgn, true);
	DeleteObject(hRgn);
	return (ret != 0);
}
int BlackMoonUI::zyForm::背景图显示方式(int 参数_图片显示方式) {
	int ShowImageType = (int)GetMember(L"ShowImageType");
	if (参数_图片显示方式 != 0) {
		SetMember(L"ShowImageType", 参数_图片显示方式);
		重画();
	}
	return (ShowImageType);
}
int BlackMoonUI::zyForm::背景图(const std::wstring& 参数_背景图路径)
{
	//Gdiplus::GpImage* pBackImage = reinterpret_cast<Gdiplus::GpImage*>(GetMember(L"pBackImage"));
	Gdiplus::Image* pBackImage = reinterpret_cast<Gdiplus::Image*>(GetMember(L"pBackImage"));
	if (pBackImage != nullptr) {
		//Gdiplus::DllExports::GdipDisposeImage(pBackImage);
		delete pBackImage;
	}

	//Gdiplus::GpImage* image = nullptr;
	//Gdiplus::Status lastResult = Gdiplus::DllExports::GdipLoadImageFromFile(路径, &image);

	Gdiplus::Image* image = Gdiplus::Image::FromFile(参数_背景图路径.c_str());
	SetMember(L"pBackImage", (LONG_PTR)image);
	//image.置指针 (pBackImage)
	重画();
	//return (image)
	return 0;
}
int BlackMoonUI::zyForm::背景图(Gdiplus::Image* pImage)
{
	Gdiplus::Image* pBackImage = reinterpret_cast<Gdiplus::Image*>(GetMember(L"pBackImage"));
	if (pBackImage != nullptr) {
		delete pBackImage;
	}

	SetMember(L"pBackImage", (LONG_PTR)pImage);

	//image.置指针 (pBackImage)
	重画();
	//return (image)
	return 0;
}
void BlackMoonUI::zyForm::背景色(COLORREF 参数_背景色 /*RGB*/) {
	SetMember(L"BackColor", 参数_背景色);
	重画();
}
COLORREF BlackMoonUI::zyForm::背景色() {
	return (COLORREF)GetMember(L"BackColor");
}
/*BOOL BlackMoonUI::zyForm::置外形(GPRegion& 参数_区域) {
	HRGN hRgn = 参数_区域.GetHRGN(nullptr);
	int ret = SetWindowRgn(取窗口句柄(), hRgn, true);
	DeleteObject(hRgn);
	return (ret != 0);
}*/
BOOL BlackMoonUI::zyForm::托盘删除图标() {
	NOTIFYICONDATA* NotifyiconData = (NOTIFYICONDATA*)GetMember(L"NotifyiconData");
	if (NotifyiconData == nullptr)
		return (false);
	return (Shell_NotifyIcon(NIM_DELETE, NotifyiconData) != 0);
}
BOOL BlackMoonUI::zyForm::取控件(int 参数_控件ID, zyCtrol& 参数_控件) {
	HWND hWnd = GetDlgItem(取窗口句柄(), 参数_控件ID);
	if (hWnd == 0)
		return (false);
	参数_控件._BindWindow(hWnd);
	return (true);
}
void BlackMoonUI::zyForm::置等待鼠标() {
	HCURSOR WaitCursor = SetCursor(LoadCursor(0, IDC_WAIT));
	SetMember(L"WaitCursor", (LONG_PTR)WaitCursor);
}
void BlackMoonUI::zyForm::恢复鼠标() {
	SetMember(L"WaitCursor", 0);
}
HWND BlackMoonUI::zyForm::取控件句柄(int 参数_控件ID)const {
	return (GetDlgItem(取窗口句柄(), 参数_控件ID));
}
int BlackMoonUI::zyForm::置开始位置(int 参数_开始位置 /*"开始位置_"开头常量。*/) {
	int StartPosition = (int)GetMember(L"StartPosition");
	if (参数_开始位置 != -1 && 参数_开始位置 < 5)
		SetMember(L"StartPosition", 参数_开始位置);
	return StartPosition;
}
int BlackMoonUI::zyForm::取开始位置() {
	return (int)GetMember(L"StartPosition");
}
BlackMoonUI::zyIcon BlackMoonUI::zyForm::取图标(BOOL 参数_是否大图标) {
	HICON hIcon = (HICON)sendMsg(WM_GETICON, 参数_是否大图标, 0);
	if (hIcon == 0)
		hIcon = LoadIcon(0, IDI_APPLICATION);
	hIcon = CopyIcon(hIcon);
	zyIcon 局部_图标;
	局部_图标.setIcon(hIcon);
	return 局部_图标;
}
void BlackMoonUI::zyForm::置图标(zyIcon& 参数_图标, BOOL 参数_是否大图标) {
	HICON hIcon;
	if (参数_是否大图标)
		hIcon = (HICON)GetMember(L"BigIcon");
	else
		hIcon = (HICON)GetMember(L"SmallIcon");
	if (hIcon != 0)
		DestroyIcon(hIcon);
	hIcon = (HICON)参数_图标.getIcon();
	if (hIcon != 0)
		hIcon = CopyIcon(hIcon);
	if (参数_是否大图标)
		SetMember(L"BigIcon", (LONG_PTR)hIcon);
	else
		SetMember(L"SmallIcon", (LONG_PTR)hIcon);
	sendMsg(WM_SETICON, 参数_是否大图标, (LPARAM)hIcon);
}
int BlackMoonUI::zyForm::返回值(int 参数_返回值) {//"对话框返回值_"开头常量。获取或设置 载入 的返回值
	if (参数_返回值 == 0)
		return (int)GetMember(L"DialogResult");
	else {
		SetMember(L"DialogResult", 参数_返回值);
		return 参数_返回值;
	}
}
BOOL BlackMoonUI::zyForm::保持标题栏激活(BOOL 参数_保持标题栏激活) {
	SetMember(L"NCEverActive", 参数_保持标题栏激活);
	return 参数_保持标题栏激活;
}
BOOL BlackMoonUI::zyForm::保持标题栏激活() {
	return GetMember(L"NCEverActive") != 0;
}
void BlackMoonUI::zyForm::置快捷键(zyAccelTable& 参数_快捷键)
{
	HACCEL pAccelTable = (HACCEL)GetMember(L"pAccelTable");
	if(pAccelTable != 0)
		DestroyAcceleratorTable(pAccelTable);
	参数_快捷键.getObject()->addRef();
	SetMember(L"pAccelTable", (LONG_PTR)参数_快捷键.取句柄());
}
BlackMoonUI::zyMenu BlackMoonUI::zyForm::取菜单() {
	zyMenu Locality_Menu;
	Locality_Menu.置菜单句柄(GetMenu(取窗口句柄()));
	return (Locality_Menu);
}
BOOL BlackMoonUI::zyForm::置菜单(zyMenu& 参数_菜单) {
	int ret = SetMenu(取窗口句柄(), 参数_菜单.取菜单句柄());
	if(!ret) return FALSE;
	if (zyWindow::是否已创建())
		重画菜单栏();
	return (ret != 0);
}
BOOL BlackMoonUI::zyForm::重画菜单栏() {
	return (DrawMenuBar(getHwnd()) != 0);
}
int BlackMoonUI::zyForm::位置(窗口位置 参数_位置) {
	HWND hwnd = getHwnd();
	int pos = -1;
	if (参数_位置 == -1) {
		if (IsIconic(hwnd) != 0)
			pos = 窗口位置_最小化;
		if (IsZoomed(hwnd) != 0)
			pos = 窗口位置_最大化;
		else
			pos = 窗口位置_通常;
		return pos;
	}
	else if (参数_位置 == 窗口位置_居中) {
		HWND hWndParent = (HWND)GetWindowLongPtr(hwnd, GWLP_HWNDPARENT);
		RECT rct = { 0 };
		RECT rectClinet = { 0 };
		if (IsWindow(hWndParent) != 0 && IsWindowVisible(hWndParent) != 0) {
			GetWindowRect(hWndParent, &rct);
			GetWindowRect(hwnd, &rectClinet);
			return (MoveWindow(hwnd, (rct.right - rct.left - (rectClinet.right - rectClinet.left)) / 2 + rct.left, (rct.bottom - rct.top - (rectClinet.bottom - rectClinet.top)) / 2 + rct.top, rectClinet.right - rectClinet.left, rectClinet.bottom - rectClinet.top, true));
		}
		else {
			int 局部_屏幕宽 = GetSystemMetrics(SM_CXSCREEN);
			int 局部_屏幕高 = GetSystemMetrics(SM_CYSCREEN);
			GetWindowRect(hwnd, &rectClinet);
			return (MoveWindow(hwnd, (局部_屏幕宽 - (rectClinet.right - rectClinet.left)) / 2, (局部_屏幕高 - (rectClinet.bottom - rectClinet.top)) / 2, rectClinet.right - rectClinet.left, rectClinet.bottom - rectClinet.top, true));
		}
	}
	if (参数_位置 == 窗口位置_通常)
		pos = SW_NORMAL;
	else if (参数_位置 == 窗口位置_最小化)
		pos = SW_MINIMIZE;
	else if (参数_位置 == 窗口位置_最大化)
		pos = SW_MAXIMIZE;
	return ShowWindow(hwnd, pos);
}
BOOL  BlackMoonUI::zyForm::Esc关闭(BOOL 参数_Esc关闭) {
	SetMember(L"EscClose", 参数_Esc关闭);
	return 参数_Esc关闭;
}
BOOL  BlackMoonUI::zyForm::Esc关闭() {
	return (GetMember(L"EscClose") != 0);
}
BOOL BlackMoonUI::zyForm::随意移动(BOOL 参数_随意移动) {
	if (参数_随意移动) 
		SetMember(L"FreeMove", 1);
	else 
		SetMember(L"FreeMove", 0);
	return 参数_随意移动;
}
int BlackMoonUI::zyForm::滚动条模式(int 参数_滚动条模式) {//获取或设置滚动条显示模式. "内置滚动条_" 开头常量组合
	int ScrollMode = (int)GetMember(L"ScrollMode");
	if (参数_滚动条模式 == -1 ) {
		return ScrollMode;
	}
	SetMember(L"ScrollMode", 参数_滚动条模式);
	return ScrollMode;
}
int BlackMoonUI::zyForm::置滚动范围(int 参数_滚动条类型, int 参数_最小值, int 参数_最大值) {//设置滚动范围
	SCROLLINFO si = {0};
	si.cbSize = sizeof(SCROLLINFO);
	si.fMask = SIF_RANGE;
	int ScrollMode = (int)GetMember(L"ScrollMode");
	if (参数_滚动条类型 == 0) {
		if ((ScrollMode & 内置滚动条_水平始终显示) != 0){
			si.fMask = si.fMask | SIF_DISABLENOSCROLL;
		}
	}
	else {
		if ((ScrollMode & 内置滚动条_垂直始终显示) != 0){
			si.fMask = si.fMask | SIF_DISABLENOSCROLL;
		}
	}	
	si.nMin = 参数_最小值;
	si.nMax = 参数_最大值;
	return SetScrollInfo(取窗口句柄(), 参数_滚动条类型, &si, true);
}
bool BlackMoonUI::zyForm::取滚动范围(int 参数_滚动条类型, int* 参数_最小值, int* 参数_最大值) {//获取滚动范围
	SCROLLINFO si = {0};
	si.cbSize = sizeof(SCROLLINFO);
	si.fMask = SIF_RANGE;
	int ret = GetScrollInfo(取窗口句柄(), 参数_滚动条类型, &si);
	*参数_最小值 = si.nMin;
	*参数_最大值 = si.nMax;
	return ret != 0;
}
int BlackMoonUI::zyForm::置滚动页(int 参数_滚动条类型, int 参数_页) {//设置每页长度
	SCROLLINFO si = { 0 };
	si.cbSize = sizeof(SCROLLINFO);
	si.fMask = SIF_PAGE;
	si.nPage = 参数_页;
	return SetScrollInfo(取窗口句柄(), 参数_滚动条类型, &si, true);
}
int BlackMoonUI::zyForm::取滚动页(int 参数_滚动条类型) {//返回每页长度
	SCROLLINFO si = { 0 };
	si.cbSize = sizeof(SCROLLINFO);
	si.fMask = SIF_RANGE;
	GetScrollInfo(取窗口句柄(), 参数_滚动条类型, &si);
	return si.nPage;
}
int BlackMoonUI::zyForm::置滚动位置(int 参数_滚动条类型, int 参数_位置) {//设置当前滚动位置
	SCROLLINFO si = { 0 };
	si.cbSize = sizeof(SCROLLINFO);
	si.fMask = SIF_POS;
	si.nPage = 参数_位置;
	return SetScrollInfo(取窗口句柄(), 参数_滚动条类型, &si, true);
}
int BlackMoonUI::zyForm::取滚动位置(int 参数_滚动条类型) {//返回当前滚动位置
	SCROLLINFO si = { 0 };
	si.cbSize = sizeof(SCROLLINFO);
	si.fMask = SIF_POS;
	GetScrollInfo(取窗口句柄(), 参数_滚动条类型, &si);
	return si.nPos;
}
bool BlackMoonUI::zyForm::显示滚动条(int 参数_滚动条类型, bool 参数_是否显示) {
	return ShowScrollBar(取窗口句柄(), 参数_滚动条类型, 参数_是否显示) != 0;
}
int BlackMoonUI::zyForm::水平滚动增量(int 参数_水平滚动增量) {//滚动一行的像素大小
	SetMember(L"scrollx_delta", 参数_水平滚动增量);
	return 参数_水平滚动增量;
}
int BlackMoonUI::zyForm::水平滚动增量() {//滚动一行的像素大小
	return (int)GetMember(L"scrollx_delta");
}
int BlackMoonUI::zyForm::垂直滚动增量(int 参数_垂直滚动增量) {//滚动一行的像素大小
	SetMember(L"scrolly_delta", 参数_垂直滚动增量);
	return 参数_垂直滚动增量;
}
int BlackMoonUI::zyForm::垂直滚动增量() {//滚动一行的像素大小
	return (int)GetMember(L"scrolly_delta");
}
POINT BlackMoonUI::zyForm::内容尺寸(const POINT& 参数_内容尺寸) {//设置虚拟内容尺寸
	SetMember(L"contentWidth", 参数_内容尺寸.x);
	SetMember(L"contentHeight", 参数_内容尺寸.y);
	return 参数_内容尺寸;
}
POINT BlackMoonUI::zyForm::内容尺寸() {//设置虚拟内容尺寸
	POINT size = { (int)GetMember(L"contentWidth") ,(int)GetMember(L"contentHeight") };
	return size;
}
POINT BlackMoonUI::zyForm::计算内容尺寸() {//计算自己的所有子窗口的最大宽度和高度
	RECT rc = {0};
	int maxRight = {0};
	int maxBottom = {0};
	HWND hWnd = 取窗口句柄();
	HWND firstChild = GetWindow(hWnd, GW_CHILD);
	HWND next = firstChild;
	while (next != 0) {
		GetWindowRect(next, &rc);
		黑月到窗口矩形(hWnd, rc);
		if (maxRight < rc.right) {
			maxRight = rc.right;
		}
		if (maxBottom < rc.bottom) {
			maxBottom = rc.bottom;
		}
		next = GetWindow(next, GW_HWNDNEXT);
	}
	return POINT{ maxRight, maxBottom };
}
void BlackMoonUI::zyForm::更新滚动条() {//当修改了 内容尺寸 或 滚动条模式 可以调用此方法
	RECT rc = 取客户区矩形();
	zyForm_OnSize(取窗口句柄(), rc.right - rc.left, rc.bottom - rc.top);
}



BOOL BlackMoonUI::zyForm::随意移动() {
	return GetMember(L"FreeMove") != 0;
}
void BlackMoonUI::zyForm::事件_可否被关闭(TRegEvent* 参数_事件指针) {
	SetRegEvent(L"OnClose", 参数_事件指针);
}
void BlackMoonUI::zyForm::事件_创建完毕(TRegEvent* 参数_事件指针) {
	SetRegEvent(L"OnCreate", 参数_事件指针);
}
void BlackMoonUI::zyForm::事件_菜单被单击(TRegEvent* 参数_事件指针) {
	SetRegEvent(L"OnMenuItemClick", 参数_事件指针);
}
void BlackMoonUI::zyForm::事件_将被销毁(TRegEvent* 参数_事件指针) {
	SetRegEvent(L"OnDestory", 参数_事件指针);
}
void BlackMoonUI::zyForm::事件_位置被改变(TRegEvent* 参数_事件指针) {
	SetRegEvent(L"OnMove", 参数_事件指针);
}
void BlackMoonUI::zyForm::事件_尺寸被改变(TRegEvent* 参数_事件指针) {
	SetRegEvent(L"OnSize", 参数_事件指针);
}
void BlackMoonUI::zyForm::事件_被激活(TRegEvent* 参数_事件指针) {
	SetRegEvent(L"OnActivate", 参数_事件指针);
}
void BlackMoonUI::zyForm::事件_被取消激活(TRegEvent* 参数_事件指针) {
	SetRegEvent(L"OnUnActivate", 参数_事件指针);
}
void BlackMoonUI::zyForm::事件_首次激活(TRegEvent* 参数_事件指针) {
	SetRegEvent(L"OnFirstActivate", 参数_事件指针);
}
void BlackMoonUI::zyForm::事件_被显示(TRegEvent* 参数_事件指针) {
	SetRegEvent(L"OnShow", 参数_事件指针);
}
void BlackMoonUI::zyForm::事件_被隐藏(TRegEvent* 参数_事件指针) {
	SetRegEvent(L"OnHide", 参数_事件指针);
}
void BlackMoonUI::zyForm::事件_托盘事件(TRegEvent* 参数_事件指针) {
	SetRegEvent(L"OnNotifIcon", 参数_事件指针);
}
void BlackMoonUI::zyForm::事件_将弹出菜单(TRegEvent* 参数_事件指针) {
	SetRegEvent(L"OnInitMenuPopup", 参数_事件指针);
}
void BlackMoonUI::zyForm::事件_菜单项热点跟踪(TRegEvent* 参数_事件指针) {
	SetRegEvent(L"OnMenuSelect", 参数_事件指针);
}
void BlackMoonUI::zyForm::事件_可否用户关闭(TRegEvent* 参数_事件指针) {
	SetRegEvent(L"OnUserClose", 参数_事件指针);
}
void BlackMoonUI::zyForm::事件_系统命令(TRegEvent* 参数_事件指针) {
	SetRegEvent(L"OnSysCommand", 参数_事件指针);
}
void BlackMoonUI::zyForm::事件_滚动条(TRegEvent* 参数_事件指针)
{
	SetRegEvent(L"OnScroll", 参数_事件指针);
}

VOID BlackMoonUI::zyForm::_开始位置到坐标(HWND parent, int StartPosition, POINT size, POINT& pos, BOOL isDialog) {
	RECT rc = { 0 };
	int w, h;
	if (StartPosition == 开始位置_居中屏幕) {//开始位置_居中屏幕
		SystemParametersInfo(SPI_GETWORKAREA, 0, &rc, 0);
		w = rc.right - rc.left;
		h = rc.bottom - rc.top;
		pos.x = (w - MulDiv(size.x, zyEnv::getInstance().getDpiForWindow(), 96)) / 2; // 测试修改BUG
		pos.y = (h - MulDiv(size.y, zyEnv::getInstance().getDpiForWindow(), 96)) / 2; // 测试修改BUG
		if (IsWindow(parent) != 0 && isDialog) {
			GetWindowRect(parent, &rc);
			pos.x = pos.x - rc.left;
			pos.y = pos.y - rc.top;
		}
	}
	else if (StartPosition == 开始位置_居中父窗口) {//开始位置_居中父窗口
		if (IsWindow(parent) != 0) {
			if (isDialog)
				GetClientRect(parent, &rc);
			else
				GetWindowRect(parent, &rc);
			w = rc.right - rc.left;
			h = rc.bottom - rc.top;
		}
		else {
			SystemParametersInfo(SPI_GETWORKAREA, 0, &rc, 0);
			w = rc.right - rc.left;
			h = rc.bottom - rc.top;
		}
		if (isDialog) {
			pos.x = (w - MulDiv(size.x, zyEnv::getInstance().getDpiForWindow(), 96)) / 2; // 测试修改BUG
			pos.y = (h - MulDiv(size.y, zyEnv::getInstance().getDpiForWindow(), 96)) / 2; // 测试修改BUG
		}
		else {
			pos.x = rc.left + (w - MulDiv(size.x, zyEnv::getInstance().getDpiForWindow(), 96)) / 2; // 测试修改BUG
			pos.y = rc.top + (h - MulDiv(size.y, zyEnv::getInstance().getDpiForWindow(), 96)) / 2; // 测试修改BUG
		}
	}
}
